/*
 * GPUC
 * 
 * Copyright © 2008 Attila T. Áfra <attila.afra@gmail.com>
 * 
 * This program is free software: you can redistribute it and/or modify it under the terms of the
 * GNU General Public License as published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along with this program. If
 * not, see <http://www.gnu.org/licenses/>.
 */

#pragma once

#include "Common.hpp"
#include "Exception.hpp"

/*------------------------------------------------------------------------------------------------*/

namespace GPUC
{   
    void createContext();
    void destroyContext();
    
#if defined(_WIN32)
    void createWglContext();
    void destroyWglContext();
#else
    void createGlxContext(const char* displayName);
    void createGlxContext(const std::string& displayName);
    void destroyGlxContext();
#endif
}

/*------------------------------------------------------------------------------------------------*/

void GPUC::createContext()
{
    const GPUC_Error error = GPUC_createContext();
    Internal::checkError(error);
}

/*------------------------------------------------------------------------------------------------*/

void GPUC::destroyContext()
{
    const GPUC_Error error = GPUC_destroyContext();
    Internal::checkError(error);
}

/*------------------------------------------------------------------------------------------------*/

#if defined(_WIN32)

/*------------------------------------------------------------------------------------------------*/

void GPUC::createWglContext()
{
    const GPUC_Error error = GPUC_createWglContext();
    Internal::checkError(error);
}

/*------------------------------------------------------------------------------------------------*/

void GPUC::destroyWglContext()
{
    const GPUC_Error error = GPUC_destroyWglContext();
    Internal::checkError(error);
}

/*------------------------------------------------------------------------------------------------*/

#else

/*------------------------------------------------------------------------------------------------*/

void GPUC::createGlxContext(const char* displayName)
{
    const GPUC_Error error = GPUC_createGlxContext(displayName);
    Internal::checkError(error);
}

/*------------------------------------------------------------------------------------------------*/

void GPUC::createGlxContext(const std::string& displayName)
{
    const GPUC_Error error = GPUC_createGlxContext(displayName.c_str());
    Internal::checkError(error);
}

/*------------------------------------------------------------------------------------------------*/

void GPUC::destroyGlxContext()
{
    const GPUC_Error error = GPUC_destroyGlxContext();
    Internal::checkError(error);
}

/*------------------------------------------------------------------------------------------------*/

#endif

/*------------------------------------------------------------------------------------------------*/
